<?php

namespace app\api\controller\info;

use app\common\controller\Api;
use app\admin\model\Userinfo as UserinfoModel;
use app\admin\model\Image;
use think\Cache;
/**
 * 示例接口
 */
class Userinfo extends Api{


    protected $noNeedRight = ['*'];
    protected $noNeedLogin = ['*'];

    public function _initialize()
    {
        parent::_initialize();
        dylog(array_merge(request()->param(), request()->header()));
    }
    public function login(){
        $account = $this->request->param("account");
        $password = $this->request->param("password");
        $verfiy = UserinfoModel::where(['account'=>$account,'password'=>$password])->select();
        if ($verfiy){
            $this->success("登陆成功");
        }else{
            $this->error("账号或密码错误");
        }
    }

    public function index(){
        $model = Image::where('switch','1')->order('weigh','desc');
        $list = $model->select();
        $result = [];
        foreach ($list as $row) {
            $result[$row->type][] = $row;
        }
        $this->success("获取",$result);

    }
    public function message(){
       $this->success("获取基本信息",UserinfoModel::all());
    }
    public function account(){
        $this->success("获取账户详情",UserinfoModel::with('deposite')->where('status',1)->select());
    }

}